import request from '@/utils/request'
export function getAllclassData(query){ //获取所有班级相关数据
    return request({
        url:'/class/query',
        method:'get',
        params:query
    })
}

export function getTeacherClassData(query){
    return request({
        url:'/asTeacherclass/selectClassManageByTeacherId',
        method:'get',
        params:query
    })
}

export function getAllGrade(){ //获取所有年级
    return request({
        url:'/grade/allGrade',
        method:'get'
    })
}

export function getAllstudentData(query){
    return request({
        url:'/dataReport/getStudentByCropAndClass',
        method:'get',
        params:query
    })
}
export function getDataReportList(data){ //获取单个学生的数据列表
    return request({
        url:`/dataReport/page?cropId=${data.cropId}&studentId=${data.studentId}`,
        method:'get'
    })
}
export function getDataReport(data){ //获取数据详情
    return request({
        url: `/dataReport/get/${data.dataReportId}`,
        method: 'get',
    })
}

export function getCropProperty(data){ //获取属性
    return request({
        url:`/cropProperty/list/${data.cropId}`,
        method:'get',
    })
}
export function saveDataReport(data){  //新增数据报表
    return request({
        url:'/dataReport/save',
        method:'post',
        data
    })
}

export function updateDataReport(data){ //更新数据报表
    return request({
        url:'/dataReport/update',
        method:'post',
        data
    })
}

export function deleteReport(data){ //删除数据报表
    return request({
        url:`/dataReport/delete/${data.dataReportId}`,
        method:'post',
    })
}

export function exportDataReprotTeacher(query){ //老师导出调查数据
    return request({
        url:'/dataReport/exportReportTeacher',
        method:'get',
        responseType: 'blob',
        params:query,
        paramsSerializer: function(params) {
            const classIds= params.classIds.map(_=>`classIds=${_}`).join('&');
            return `${classIds}&cropId=${query.cropId}&teacherId=${query.teacherId}`
        }
    })
}

export function exportDataReportStudent(query){ //学生导出数据
    return request({
        url:'/dataReport/exportReportStudent',
        method:'get',
        responseType: 'blob',
        params:query,
        
    })
}

export function statistic(ids){
    return request({
        url:'/dataReport/statisticalAnalysis',
        method:'get',
        params:{ids:[ids]},
        paramsSerializer: function(params) {
            const ids= params.ids.map(_=>`ids=${_}`).join('&');
            return `${ids}`
        }
    })
}